home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOpus Plus
/
DOpus Plus.iso
/
Tutorial
/
C Guide
/
Code_Fragments
/
LoadList.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-09-18
|
1KB
|
58 lines
/*
LoadList.c - Loads/writes an ASCII List to/from an Att_List
*/
#include <proto/dos.h>
#include <proto/exec.h>
#define _DOPUS_MODULE_DEF
#include <dopus/modules.h>
#define SDI_TO_ANSI
#include <sdi_std.h>
/********************************************************************/
Att_List *LoadList( STRPTR filename )
{
BPTR file;
char buffer[256];
Att_List *list = NULL;
if( (file = Open(filename, MODE_OLDFILE)) )
{
list = Att_NewList( LISTF_POOL );
while( FGets(file, buffer, 256) )
{
buffer[strlen(buffer)-1] = 0x00;
Att_NewNode( list, buffer, NULL, NULL );
}
Close( file );
}
return list;
}
/********************************************************************/
void WriteList( Att_List *entrylist, STRPTR header )
{
BPTR file;
ULONG count = 0;
STRPTR out;
file = Open( TEMP_FILE, MODE_NEWFILE );
if( header )
FPuts( file, header );
while( (out = Att_NodeName(entrylist, count++)) )
FPuts( file, out );
Close( file );
}